package com.example.DBHelper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Build;

/**
 * 建立一个数据库帮助类
 */
public class DBHelper extends SQLiteOpenHelper {
	// download.db-->数据库名
	public DBHelper(Context context, boolean enableWAL) {
		super(context, "download.db", null, 1);
		 if( enableWAL && Build.VERSION.SDK_INT >= 11){  
	            getWritableDatabase().enableWriteAheadLogging();  
	        }
	}
	/**
	 * 在download.db数据库下创建一个download_info表存储下载信息
	 */
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("create table download_info(_id integer PRIMARY KEY AUTOINCREMENT, thread_id integer, "
				+ "start_pos integer, end_pos integer, compelete_size integer,listen_itemid char,listen_blid char, "
				+ "listen_name char, listen_title char,listen_id char,url char,listen_tag char,listen_thumb char,filesize Integer)");
		
		
		db.execSQL("create table listen_info(_id integer PRIMARY KEY AUTOINCREMENT, listen_itemid char,listen_blid char, "
				+ "listen_name char, listen_title char,listen_id char, listen_size integer,listen_url char,listen_tag char,listen_thumb char,filesize Integer)");
		
		
		db.execSQL("create table listen_down(_id integer PRIMARY KEY AUTOINCREMENT, listen_itemid char,listen_blid char, "
				+ "listen_name char, listen_title char,listen_id char, listen_size integer,listen_url char,listen_tag char,listen_thumb char,filesize Integer)");
	}
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}
	@Override
	public void onOpen(SQLiteDatabase db) {
		super.onOpen(db);
	}
	

}
